#!/bin/bash

# 定义脚本文件路径
INSTALL_VIRTUALBOX_SCRIPT="install_virtualbox.sh"
INSTALL_VAGRANT_SCRIPT="install_vagrant.sh"

# 检查脚本文件是否存在
if [ ! -f "$INSTALL_VIRTUALBOX_SCRIPT" ]; then
  echo "Error: $INSTALL_VIRTUALBOX_SCRIPT not found."
  exit 1
fi

if [ ! -f "$INSTALL_VAGRANT_SCRIPT" ]; then
  echo "Error: $INSTALL_VAGRANT_SCRIPT not found."
  exit 1
fi

# 赋予脚本执行权限
chmod +x "$INSTALL_VIRTUALBOX_SCRIPT" "$INSTALL_VAGRANT_SCRIPT"

# 安装 VirtualBox
echo "Installing VirtualBox..."
sudo ./"$INSTALL_VIRTUALBOX_SCRIPT"
if [ $? -ne 0 ]; then
  echo "Error: Failed to install VirtualBox."
  exit 1
fi

# 安装 Vagrant
echo "Installing Vagrant..."
sudo ./"$INSTALL_VAGRANT_SCRIPT"
if [ $? -ne 0 ]; then
  echo "Error: Failed to install Vagrant."
  exit 1
fi

echo "Installation completed successfully."